﻿package mortal.game.view.copy.QuestionCopy.panel
{
    import Message.DB.Tables.*;
    import __AS3__.vec.*;
    import com.gengine.resource.*;
    import com.mui.controls.*;
    import extend.language.*;
    import flash.events.*;
    import mortal.common.global.*;
    import mortal.component.window.*;
    import mortal.game.events.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.rules.*;
    import mortal.game.view.common.*;
    import mortal.game.view.common.item.*;
    import mortal.game.view.guildNew.*;
    import mortal.mvc.core.*;
    import mortal.mvc.interfaces.*;

    public class QuestionCopyEnterWindow extends ActivityBaseWindow
    {
        private var _vcRewardItem:Vector.<BaseItem>;
        private var _btnHonerShop:GButton;
        private var _isUILoad:Boolean = false;
        private static var _instance:QuestionCopyEnterWindow;

        public function QuestionCopyEnterWindow(param1:ILayer = null)
        {
            this._vcRewardItem = new Vector.<BaseItem>;
            setSize(696, 412);
            super(param1, ImagesConst.QuestionTitle, ImagesConst.QuestionCopyEnter);
            return;
        }// end function

        override protected function configParams() : void
        {
            _titleSpriteHight = 400;
            super.configParams();
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            var _loc_3:int = 0;
            var _loc_4:BaseItem = null;
            super.createDisposedChildrenImpl();
            pushUIToDisposeVec(UIFactory.gTextField(Language.getStringByParam(71401, ActionTimeShowUtil.instance.QuestionStr), 201, 361, 300, 20, this, GlobalStyle.textFormatHuang2.setSize(13).center()));
            var _loc_1:Number = 228;
            var _loc_2:Number = 318;
            _loc_3 = 0;
            while (_loc_3 < 6)
            {
                
                _loc_4 = UIFactory.getUICompoment(BaseItem, _loc_1 + 44 * _loc_3, _loc_2, this._contentTopOf3DSprite);
                _loc_4.setItemStyle(ItemStyleConst.Small, ImagesConst.PackItemBg, 2, 2);
                this._vcRewardItem.push(_loc_4);
                _loc_3++;
            }
            LoaderHelp.addResCallBack(ResFileConst.questionCopy, this.onShowWin);
            this._btnHonerShop = UIFactory.gButton("" + Language.getString(70957), 530, 323, 65, 22, this._contentTopOf3DSprite, "GreenLinkButton");
            this._btnHonerShop.configEventListener(MouseEvent.CLICK, this.onClickHonorShop);
            this.updateRewardsItems();
            this._btnHonerShop.visible = false;
            return;
        }// end function

        private function onShowWin() : void
        {
            this._isUILoad = true;
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            this._isUILoad = false;
            this._btnHonerShop.dispose(param1);
            this._btnHonerShop = null;
            var _loc_2:int = 0;
            while (_loc_2 < this._vcRewardItem.length)
            {
                
                this._vcRewardItem[_loc_2].dispose(param1);
                _loc_2++;
            }
            this._vcRewardItem.length = 0;
            super.disposeImpl(param1);
            return;
        }// end function

        protected function updateRewardsItems() : void
        {
            var _loc_1:* = CopyConfig.instance.getCopyInfoByCode(127);
            var _loc_2:* = _loc_1.rewardShow.split("#");
            var _loc_3:* = Math.min(8, _loc_2.length);
            var _loc_4:int = 0;
            while (_loc_4 < _loc_3)
            {
                
                this._vcRewardItem[_loc_4].itemCode = int(_loc_2[_loc_4]);
                _loc_4++;
            }
            return;
        }// end function

        override protected function onClickEnterBtn(event:MouseEvent) : void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.CopyQuestionRequestEnter));
            return;
        }// end function

        private function onClickHonorShop(event:MouseEvent) : void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.NPC_OpenNpcShop, ShopType.Honor));
            return;
        }// end function

        override public function show(param1:int = 0, param2:int = 0) : void
        {
            super.show();
            return;
        }// end function

        public static function get instance() : QuestionCopyEnterWindow
        {
            if (_instance == null)
            {
                _instance = new QuestionCopyEnterWindow;
            }
            return _instance;
        }// end function

        public static function hasInstance() : Boolean
        {
            return _instance != null;
        }// end function

    }
}
